package com.xfcy.blog.strategy.impl;

import com.xfcy.blog.service.ElasticSearchService;
import com.xfcy.blog.strategy.SearchStrategy;
import com.xfcy.blog.vo.ArticleSearchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 晓风残月Lx
 * @date 2023/4/12 15:26
 */
@Service("elasticsearchStrategyImpl")
public class EsSearchStrategyImpl implements SearchStrategy {

    @Resource
    private ElasticSearchService elasticSearchService;

    /**
     * 根据关键词查简介和标题
     * @param keywords
     * @return
     */
    @Override
    public List<ArticleSearchVO> searchArticle(String keywords) {
        return elasticSearchService.searchArticleByTitleAndSummary(keywords);
    }
}
